package ru.study.thinkin.chapter11;

import  java.util.*;

class Person {
	private String name;
	public Person(String name) {
		this.name= name;
	}
	@Override
	public String toString() {	
		return name;
	}
	
}

public class MapOfList {
	public static Map<Person,List<? extends Pet>> petPeople = new HashMap<Person,List<? extends Pet>>();        
	
	static {
		petPeople.put(new Person("Dawn"),Arrays.asList(new Cat("Molly"),new Dog("Taddy")));
		petPeople.put(new Person("Hilary"),Arrays.asList(new Rat("Little"),new Hamster("Crush")));
		
	}
	
	public static void main(String[] args) {
		System.out.println("People:"+petPeople.keySet());
		for(Map.Entry <Person,List<? extends Pet>> entry : petPeople.entrySet()) {
			System.out.println("person "+ entry.getKey().toString() + " has ");
			
			List pets = entry.getValue();
			Iterator <? extends Pet> it = pets.iterator();
			while(it.hasNext()) {
				Pet p = it.next();
				System.out.print(p.getClass().getSimpleName()+" ");
				System.out.println(p.name);
				
			}			
		}
	}

}
